<?php
	class FNode{
	
		public function __construct($item){
		}
	
		/* 0:coefficient; 1:variable; 2: functions; 3:Operators; 4: ( or ) */
		public $functCode;
		
		/* This is used for operators & functions */
		public $priority;
		
		/* SEE: flags section */
		public $chr;
		
		/*
		 TYPE_FLOATING_POINT OR TYPE_FRACTION
		 * */
		public $valueType;
		
		public $value;
		public $frValue;
		
		/* this flag is just used for FUNCTIONs and VARIABLEs cause they cannot express its sign itself */
		/* MUST = 1 by default */
		public $sign;
		
		public $parent;
		public $left;
		public $right;
	}
	
	class Funct{
		public $str = "";
		public $len = 0;
		public $prefix;
		public $prefixLen = 0;
		public $vars = null;
		
		public function __construct(){
		}
		
		protected function isVariable($c){
			return strpos($str, $c);
		}
		
		protected function getPriority($c){
			switch(ord($c)){
				case 0x2B:
				case 0x2D:
					return 0x01;
				
				case 0x2A:
				case 0x2F:
					return 0x02;
				
				case 0x5E:
					return 0x03;
			}
			
			return 0x01;
		}
		
		public function addItem2Prefix($item){
			if($item == null)
				return null;
				
			if($prefixLen == 0){
				$prefix = array();
				$prefix[$prefixLen] = $item;
				$prefixLen++;
				return;
			}
			
			$prefix[] = $item;
			$prefixLen++;
		}
		
	}
?>